package Hot100.Tree;

public class sortedArrayToBST {
    public static void main(String[] args) {
        int[] value = {-10,-3,0,5,9};
        new sortedArrayToBST().sortedArrayToBST(value);
    }
    public  TreeNode sortedArrayToBST(int[] nums) {
        int left = 0,right = nums.length-1;
        TreeNode root = inorder(nums,left,right);

        return root;
    }
    public  TreeNode inorder(int[] nums,int left ,int right){
        if(left > right)
            return null;
        int mid = (left + right) / 2;
        System.out.println(nums[mid]);
        TreeNode root = new TreeNode(nums[mid]);
        root.left = inorder(nums,left,mid-1);
        root.right = inorder(nums,mid+1,right);
        return root;
    }
}
